//#pragma once

#ifndef __ITERATOR_H__
#define __ITERATOR_H__

template<class Iterator, class Ref, class Ptr>
struct ReverseIterator
{
	typedef ReverseIterator<Iterator, Ref, Ptr> self;

	ReverseIterator(Iterator it = nullptr)
		: _it(it)
	{}

	Ref operator*()
	{
		Iterator tmp = _it;
		--tmp;

		return *tmp;
	}

	Ptr operator->()
	{
		return &(operator*());
	}

	self& operator++()
	{
		--_it;

		return *this;
	}

	self& operator--()
	{
		++_it;

		return *this;
	}

	self operator++(int)
	{
		self tmp(*this);
		++(*this);

		return tmp;
	}

	self operator--(int)
	{
		self tmp(*this);
		--(*this);

		return tmp;
	}

	bool operator==(const self& s) const
	{
		return _it == s._it;
	}

	bool operator!=(const self& s) const
	{
		return _it != s._it;
	}

	Iterator _it;
};

#endif
